#ifndef _Queue_h_
#define _Queue_h_
#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
#include <boost/thread/mutex.hpp>

// forward declaration
template <typename T> class Queue;
template <typename T> class Node;


template <typename T>
class Node {
private:
	Node* next;
	Node* prev;
	T* data;
public:
	Node();
	~Node();
	T* getData();
	void print();	
	friend class Queue<T>;
};


template <typename T>
class Queue {
private:
	int size;
	Node<T>* head;
	Node<T>* tail;
public:
	Queue();
	void enqueue(T* entry);
	T* dequeue();
	T* peek();
};

template <typename T> Node<T>::Node() {
	data = NULL;
	next = NULL;
	prev = NULL;
}

template <typename T> Queue<T>::Queue() {
	head = NULL;
	tail = NULL;
	size = 0;
}

template <typename T> void Queue<T>::enqueue(T* entry) {
	if (!head) {
		// no queue exists
		// create a new head/tail node
		Node<T>* node = new Node<T>();
		node->data = entry;
		head = node;
		tail = node;
	} else {
		Node<T>* node = new Node<T>();
		node->prev = tail;
		node->data = entry;
		tail->next = node;
		tail = node;
	}
	size++;
}

//template <typename T> void Queue<T>::enqueue(T* entry) {
	//if (!

template <typename T> T* Queue<T>::peek() {
	return head->data;
}

template <typename T> void Node<T>::print() {
	cout << "data: " << data << endl;
}
#endif